import Paging from '../../../wxjs/Paging.js'
import navToNext from '../../../wxjs/navToNext.js'
const app = getApp();

var pag = new Paging();

var data = {
  xhx_images: app.xhx_images,
  xhx_route: app.xhx_route,
};

var currentPage = {
  data,
  reqUrl: app.serAddrs.addrList,
  onLoad,
  addrDel,
};

var page = Object.assign({}, pag.func(), navToNext, currentPage);

Page(page)

function onLoad() {
  const that = this;
  // 初始化
  that.pageListInit();
}

function addrDel(event){
  const that = this;
  const index = event.currentTarget.dataset.index;
  let lists = that.data.lists || [];

  app.middleware.requestAjax({
    serAddr: app.serAddrs.addrDel,
    data: {
      uuid:lists[index].uuid
    },
    success: function (res) {
      lists.splice(index,1);
      that.setData({
        lists
      })
    },
    fail: function (res) {
      app.middleware.showToast(res && res.msg || "请求失败");
    }
  })
}